unit IThread;

interface

uses
  Winapi.Windows, System.Classes, System.SysUtils;

type
  TIThread = class(TThread)
  private
    FName: String;
    FIsClose: Boolean;
  protected
    procedure Execute; override;
    procedure ThreadRoutine; virtual; abstract;
  public
    constructor Create;
    destructor Destroy; override;
    procedure RunThread;
    procedure CloseThread; virtual;
  published
    property Name: String read FName write FName;
    property IsClose: Boolean read FIsClose write FIsClose;
  end;

implementation

{ TIThread }

constructor TIThread.Create;
begin
  inherited Create(True);
  FIsClose := False;
end;

destructor TIThread.Destroy;
begin
  inherited Destroy;
end;

procedure TIThread.Execute;
begin
  try
    ThreadRoutine;
  except
    on E: Exception do MessageBox(0, PChar(E.Message), nil, MB_OK);
  end;
end;

procedure TIThread.RunThread;
begin
  Resume;
end;

procedure TIThread.CloseThread;
begin
  FIsClose := True;
end;

end.
